package com.derek.omeshopping.ui.classify;


import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;


import com.derek.omeshopping.R;
import com.derek.omeshopping.base.BaseFragment;
import com.derek.omeshopping.bean.classify.ClassifyLeftListViewBean;

import java.util.List;

/**
 * Created by asus on 2016/10/17 09 49.
 * 邮箱:763433963@qq.com
 * 该fragment用于实现分类页面
 */
public class ClassifyFragment   extends BaseFragment implements ClassifyContract.View {
    private ClassifyPresenter presenter;
    private Handler handler=new Handler();
    private ListView lv;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_classify,null);
        presenter=new ClassifyPresenter(this);
        presenter.getListViewFromNet();
        lv= (ListView) view.findViewById(R.id.lv_classify_left);
        return view;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_classify;
    }

    @Override
    public void onListViewSuccess(final List<ClassifyLeftListViewBean> list_left) {
        handler.post(new Runnable() {
            @Override
            public void run() {
                //进行适配
                ClassifyLeftListViewAdapter adapter=new ClassifyLeftListViewAdapter(list_left,getActivity());
                lv.setAdapter(adapter);
            }
        });



    }

    @Override
    public void onListViewFail(String msg) {

    }
}
